﻿/* 2014/8/3 */
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace PictureManager.Option
{
    class ColumnDefinitionListViewItem : ListViewItem
    {
        private DynamicColumnDefinitionInfo _column;

        public ColumnDefinitionListViewItem(string name, string header, int width, bool enabled)
            : base(new string[] { name, header, width.ToString(), enabled.ToString() })
        {
            _column = new DynamicColumnDefinitionInfo()
            {
                Name = name,
                Header = header,
                Width = width,
                Enabled = enabled,
            };
        }

        public ColumnDefinitionListViewItem(DynamicColumnDefinitionInfo column) :
            base(new string[] { column.Name, column.Header, column.Width.ToString(),
                column.Enabled.ToString() })
        {
            _column = column;
        }

        public DynamicColumnDefinitionInfo ColumnDefinition
        {
            get
            {
                return _column;
            }
        }

        public string ColumnName
        {
            get
            {
                return _column.Name;
            }
            set
            {
                _column.Name = value;
                SubItems[0].Text = value;
            }
        }

        public string ColumnHeader
        {
            get
            {
                return _column.Header;
            }

            set
            {
                _column.Header = value;
                SubItems[1].Text = value;
            }
        }

        public int ColumnWidth
        {
            get
            {
                return _column.Width;
            }

            set
            {
                _column.Width = value;
                SubItems[2].Text = value.ToString();
            }
        }

        public bool ColumnEnabled
        {
            get
            {
                return _column.Enabled;
            }

            set
            {
                _column.Enabled = value;
                SubItems[3].Text = value.ToString();
            }
        }
    }
}
